#tag Module
Protected Module unitTests
	#tag Method, Flags = &h0
		Sub Run()
		  dim started as double
		  dim finished as double
		  dim time as string
		  
		  dim pMb as new MemoryBlock(0)
		  pStream = new BinaryStream(pMb)
		  dim fMb as new MemoryBlock(0)
		  fStream = new BinaryStream(fMb)
		  
		  System.Log(System.LogLevelCritical, "===== unitTests start =====")
		  
		  started = Microseconds
		  board.testboard.run
		  game.testgame.run
		  
		  finished = Microseconds
		  
		  time = str((finished - started)/1000000) + " seconds"
		  System.Log(System.LogLevelCritical, "Failed: " + str(failed))
		  System.Log(System.LogLevelCritical, "Passed: " + str(passed))
		  System.Log(System.LogLevelCritical, "Total: " + str(total))
		  System.Log(System.LogLevelCritical, "Time taken: " + time + " seconds")
		  System.Log(System.LogLevelCritical, "===== unitTests stop =====")
		  
		  testRunner.txtTime.Text = time
		  testRunner.txtFailed.Text = str(failed)
		  testRunner.txtPassed.Text = str(passed)
		  testRunner.txtTotal.Text = str(total)
		  testRunner.txtClasses.Text = str(classes)
		  testRunner.txtMethods.Text = str(methods)
		  
		  testRunner.txtPassed.Text = pStream.ReadPString
		  testRunner.txtFailed.Text = fStream.readPString
		  
		  
		  winMain.Visible = false
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub ErrorIfNotEqual(name as string, msg as string)
		  
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub TestFailed(msg as string)
		  unitTests.methods = unitTests.methods + 1
		  unitTests.failed = unitTests.failed + 1
		  'testRunner.edtFailed.Text = testRunner.edtFailed.Text + msg + EndOfLine
		  fStream.WritePString(msg + EndOfLine)
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub TestPassed(msg as string)
		  unitTests.methods = unitTests.methods +1
		  unitTests.passed = unitTests.passed + 1
		  testRunner.edtPassed.Text = testRunner.edtPassed.Text + msg + EndOfLine
		  pStream.WritePString(msg + endofline)
		End Sub
	#tag EndMethod

	#tag Method, Flags = &h0
		Sub reset()
		  testRunner.edtPassed.Text = ""
		  testRunner.edtFailed.Text = ""
		  classes = 0
		  failed = 0
		  methods = 0
		  passed = 0
		  
		End Sub
	#tag EndMethod


	#tag Property, Flags = &h1
		#tag Note
			Stores the value of the passed unitTests
		#tag EndNote
		Protected passed As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h1
		#tag Note
			stores the values of the failed unitTests
		#tag EndNote
		Protected failed As Integer = 0
	#tag EndProperty

	#tag ComputedProperty, Flags = &h1
		#tag Getter
			Get
			return failed + passed
			End Get
		#tag EndGetter
		Protected total As Integer
	#tag EndComputedProperty

	#tag Property, Flags = &h1
		#tag Note
			number of classes tested
		#tag EndNote
		Protected classes As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h1
		#tag Note
			number of methods tested
		#tag EndNote
		Protected methods As Integer = 0
	#tag EndProperty

	#tag Property, Flags = &h1
		Protected pStream As binaryStream
	#tag EndProperty

	#tag Property, Flags = &h1
		Protected fStream As binaryStream
	#tag EndProperty


	#tag ViewBehavior
		#tag ViewProperty
			Name="Name"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Index"
			Visible=true
			Group="ID"
			InitialValue="-2147483648"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Super"
			Visible=true
			Group="ID"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Left"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
		#tag ViewProperty
			Name="Top"
			Visible=true
			Group="Position"
			InitialValue="0"
			InheritedFrom="Object"
		#tag EndViewProperty
	#tag EndViewBehavior
End Module
#tag EndModule
